package com.runa.rccprotocol.flightControl;

import com.rn.smart.command.dto.valve.contro.FeiKongValve;
import com.runa.monitor.comm.entity.CommValve;
import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 2024/9/6 13:53
 * zhangYB
 */
@Data
public class ValveOutTemperatureControlRequest {

    /**
     * type: 控制类型，值包括：”开启自控”、”关闭测温”、”只开启测温”
     * 1. 开启自控：开启回温自动控制
     * 2. 关闭测温：关闭回温自动控制、关闭测温
     * 3. 只开启测温：开启管道测温，但不会根据温度自控
     */
    private String type;

    /**
     * controlCycle：控制周期，单位分钟，最小 3 分钟，取值范围 3-255
     */
    private String controlCycle;

    /**
     * controlOutTemperature：控制阈值，表示回温控制的目标值，整数
     */
    private String controlOutTemperature;

    private List<ValveControlParameter> terminalValvesBatchControlParameters;


    public static ValveOutTemperatureControlRequest getRequestBody(FeiKongValve feiKongValve, CommValve commValve) {
        ValveControlParameter valveControlParameter = ValveControlParameter.getInstance(feiKongValve, commValve);
        ValveOutTemperatureControlRequest request = new ValveOutTemperatureControlRequest();
        request.setType("1");
        request.setControlOutTemperature(feiKongValve.getValue());
        request.setTerminalValvesBatchControlParameters(new ArrayList<>(Arrays.asList(valveControlParameter)));
        return request;

    }

}
